﻿#ifndef ADDRESSBOOKMODEL_H
#define ADDRESSBOOKMODEL_H


#include <QAbstractItemModel>
#include <QStandardItemModel>
#include <QVariant>
#include <QModelIndex>
#include <QStringList>
#include "AddressBookHelper.h"

class AddressBookModel : public QAbstractItemModel
{
    Q_OBJECT
public:
    AddressBookModel(QObject* parent = nullptr);

    virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
    virtual QModelIndex parent(const QModelIndex &child) const;
    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
    virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
    virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
    virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);

    QModelIndex getFirstItemByIndex(const int& index);

    int getIndexByScrollBarValue(const int& iValue);

private:
    QList<MemberInfo>      m_dataList;
};
#endif // ADDRESSBOOKMODE_H
